window.addEventListener("load", function () {
	let name = $("#usname");
	let passwordNode = $("#keys");
	// 密码
	const regex3 = /^\w{6,12}$/;
	// 输入框
	const regex2 = /^[a-zA-Z0-9]{6,20}$/;

	$("input").forEach(function (v) {
		v.addEventListener("blur", function () {
			if (regex2.test(name.value)) {
				$("#ms").textContent = "";
			} else {
				$("#ms").textContent = "请输入6~20字母或数字";
			}
			if (regex3.test(passwordNode.value)) {
				$("#mp").textContent = "";
			} else {
				$("#mp").textContent = "请输入6~12的密码";
			}
		});
	});

	$("#loginForm").addEventListener("submit", function (event) {
		if (regex2.test(name.value) && regex3.test(passwordNode.value)) {
		} else {
			// 阻止提交
			event.preventDefault();
		}
		// 表单验证函数
		// 验证表单
	});

	$(".layerTab a").forEach(function (v, i) {
		v.addEventListener("click", function () {
			// 清除所有
			$(".layerTab a").forEach(function (item, index) {
				// 清除激活
				item.classList.remove("active");
				// 清除form
				$("#layer form")[index].style.display = "none";
			});
			// this.classList.add("active");
			// $("#layer form").forEach(function (each) {
			// 	each.style.display = "none";
			// 	console.log(each);
			// });
			$("#layer form")[i].style.display = "block";
		});
	});
});
